package Internet.Program.UDP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

/**
 * @Author: Jason
 * @ClassName: UDPClientDemo1
 * @Description: UDP
 * @Package：Internet.Program.UDP
 * @Project：javaDemo
 * @name：UDPClientDemo1
 * @Filename：UDPClientDemo1
 **/

public class UDPClientDemo1 {
    public static void main(String[] args) throws Exception {
        //1、简历一个socket
        DatagramSocket socket = new DatagramSocket();
        //2、建包
        String msg = "hello";

        //发送给谁
        InetAddress localhost = InetAddress.getByName("127.0.0.1");
        int port = 9090;

        DatagramPacket datagramPacket = new DatagramPacket(msg.getBytes(), 0, msg.getBytes().length,localhost,port);
        //3、发送包
        socket.send(datagramPacket);
    }

}
